/*

Copyright (C) 2010  Christoph Schnack 

    This file is part of Tribuit.

    Tribuit is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    Tribuit is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with Tribuit.  If not, see <http://www.gnu.org/licenses/>.
*/
package GuiTools;

import java.awt.Point;
import javax.swing.JFrame;
import Mainframe.Mainframe;

/**
 * Stores the currently opened manage dialog and focuses it when the TribuitMenu button for the source dialog is clicked.
 * 
 * @author Christoph Schnack
 * @see MDTribuitFrame
 */
public class MDManager {
	TribuitFrame CURRENTDIALOG;
	Mainframe MAINFRAME;
	
	public MDManager(Mainframe mf){
		MAINFRAME=mf;
	}
	public void focusCurrentDialog(){
		if(CURRENTDIALOG.getState()==JFrame.ICONIFIED) CURRENTDIALOG.setState(JFrame.NORMAL);
		Point pos = MAINFRAME.getLocationOnScreen();
		CURRENTDIALOG.setLocation(pos.x+MAINFRAME.getWidth(),pos.y);
		CURRENTDIALOG.requestFocus();
	}
	
	public void setCurrentDialog(TribuitFrame frame){
		CURRENTDIALOG=frame;
	}
	
	public TribuitFrame getCurrentDialog(){
		return CURRENTDIALOG;
	}
	
	public boolean isRunning(){
		if(CURRENTDIALOG==null || !CURRENTDIALOG.isDisplayable()) return false;
		else return true;
	}

}
